﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Fluid.Controls;
using TouchRC.Custom_Controls.Events;
using TouchRC.Classes;

namespace TouchRC.Custom_Controls
{
    public class MenuOptionControl : FluidLabel
    {
        #region Private Members

        private int m_Index = -1;
        private MainMenuItem m_Item;

        #endregion

        public MenuOptionControl(MainMenuItem item)
            : base ()
        {
            m_Item = item;
            base.Text = m_Item.Title;
        }

        protected override void InitControl()
        {
            base.InitControl();
            base.Click += new EventHandler(MenuOptionControl_Click);
        }

        public override bool Active { get { return true; } }

        void MenuOptionControl_Click(object sender, EventArgs e)
        {
            if (ItemClick != null)
            {
                MenuOptionEventArgs args = new MenuOptionEventArgs();
                args.Options = m_Item.Options;
                args.SelectedItemIndex = m_Index;

                ItemClick(this, args);
            }
        }

        public override bool OnClick(PointEventArgs e)
        {
            if (ItemClick != null)
            {
                MenuOptionEventArgs args = new MenuOptionEventArgs();
                args.Options = m_Item.Options;
                args.SelectedItemIndex = m_Index;

                ItemClick(this, args);
            }
            else
            {
                return base.OnClick(e);
            }
            return false;
        }

        public event EventHandler<MenuOptionEventArgs> ItemClick;

        public int Index { get { return m_Index; } set { m_Index = value; } }
    }
}
